BoolExtractPolygons
Section: C Library Functions (3)
Updated: IRIT Version 6.0
Index
Return to Main Contents
NAME
BoolExtractPolygons()
SYNOPSIS
bool_lib/bool2low.c:889
IPObjectStruct *BoolExtractPolygons(IPObjectStruct *PObj, int AinB)
DESCRIPTION
This routine coordinates all the extraction of the polygons from the
intersecting lists. Does it in the following steps:
1. Mark all polygons with no intersection at all as complete polygons.
(this is because this polygon will be totally in or out, according
to inter-polygon adjacencies propagation...)
Also mark them as undefined (if in output or undefined) yet.
Uses IPPolygonStruct Tags to save these bits.
2. do
2.1. Convert the unordered segment list of each polygon to closed loops
(if create a hole in polygon) or open (if crosses its boundary).
2.2. Order the open loops along the perimeter of the polygon (note
these loops cannt intersect. For example (5 vertices polygon):
-----------------------------L3
| ---------------L1 -----L2 | --------L4 --L5
| | | | | | | | | |
P0 ------ P1 ------- P2 ----- P3 -------- P4 ------ P5 -------- P0
Note L1, L2 are enclosed in L3 loop, and that the order is
circular.
2.3. "Break" the polygon at each open loop that has no enclosed loops
in it. For example we can start at L1, L2, L4, L5 and then L3.
"Break" means - replace the vertex chain between the two loop end
points, with the loops itself. Depends upon the relation required
we may need to output a new polygon form from the deleted chain
and that loop. In addition we may form a new polygon from last
loop and was was left from the original polygon
For each formed polygon, for each complete edge of it (i.e. edge
which was originally in the polygon) test the adjacent polygon
if it is complete (as marked in 1.) and if in or undefined (marked
undefined in 1.) is still undefined:
2.3.1. set it to be in.
2.3.2. push it on adjacency stack.
2.4. For each closed loop - find in which polygon (from polygons
created in 2.3.) it is enclosed, and decompose it.
3. While adjacencies stack not empty do:
3.1. pop top polygon from stack and output it.
3.2. For each of its edges (which obviousely must be complete edges)
if adjacent polygon is complete and undefined:
3.3.1. set it to be in.
3.3.2. push it on adjacency stack.
3.3 go back to 3.
The above algorithm defines in as in output, but dont be confused with
the required inter-object AinB (or AoutB if FALSE), which used to
determine which side of the trimming loop should be output.
Note this routine may return non-convex polygons (but marked as so) even
though the input for the booleans must be convex polygons only!
In order to keep the given object unchanged, a whole new copy off the
polygon list is made. The polygons of the list that are not in the output
are freed: a global list of all polygons (pointers) is used to scan them
in the end and free the unused ones (list PolysPtr).
PARAMETERS:
PObj: Object that need to be rebuilt according to the intersection
curves that were found, both closed and open loops.
AinB: Type of inclusion/exclusion requested.
FUNCTION RETURN VALUE
IPObjectStruct *: The newly created clipped object.
ORIGIN
(C) Copyright 1989/90-95 Gershon Elber, Technion, IIT
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- PARAMETERS:
-
- FUNCTION RETURN VALUE
-
- ORIGIN
-
This document was created by
man2html,
using the manual pages.
Time: 07:27:11 GMT, October 17, 2022